<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Products extends CI_Controller {

	public function index()
	{
		//modell
		$this->load->model('Products_model');
		$this->load->model('Orderedcategories_model');

		$data['products_model'] = $this->Products_model;
		$data['categories'] = $this->Orderedcategories_model;
		$data['selected_category_id'] = -1;
		$data['bread_crumbs'] = $this->Products_model->breadCrumbs(-1);
		
		//view
		$this->load->view('products', $data);
	}
	
	public function category($id) {
		//modell
		$this->load->model('Products_model');
		//$this->load->model('Categories_model');
		$data['products_model'] = $this->Products_model;
		$data['selected_category_id'] = $id;
		
		$data['bread_crumbs'] = $this->Products_model->breadCrumbs($id);
		//view
		//$this->load->view('head');
		$this->load->view('header', array('activeLink' => "products"));
		$this->load->view('products', $data);
        $this->load->view('footer'); 
	}
	
	public function info($productId) {
		$this->load->model('Products_model');
		$data['products_model']     = $this->Products_model;
		$data['current_product_id'] = $productId;
		
		$prodCatID = $this->Products_model->getProductById($productId)->category_id;
		$data['selected_category_id'] = $prodCatID;
		$data['bread_crumbs'] = $this->Products_model->breadCrumbs($prodCatID);
		//view
		$this->load->view('head');
		$this->load->view('header', array('activeLink' => "products"));
		$this->load->view('productinfo', $data);
		$this->load->view('footer'); 
	}
}

/* End of file products.php */
/* Location: ./application/controllers/products.php */